package com.coincalf.exchange.service;

import com.baomidou.mybatisplus.service.IService;
import com.coincalf.exchange.entity.EntrustOrder;
import com.coincalf.exchange.entity.ForexAccount;
import com.coincalf.exchange.entity.Market;
import com.coincalf.exchange.entity.TurnoverOrder;
import com.coincalf.framework.enums.TradeType;
import com.coincalf.framework.exception.ForexAccountException;

import java.math.BigDecimal;

/**
 * <p>
 * 创新交易持仓信息 服务类
 * </p>
 *
 * @author qiang
 * @since 2018-05-12
 */
public interface ForexAccountService extends IService<ForexAccount> {

    /**
     * 创新交易平仓
     *
     * @param market       交易对
     * @param dealOrder    成交订单
     * @param entrustOrder 委托订单
     */
    void closePosition(Market market, TurnoverOrder dealOrder, EntrustOrder entrustOrder);

    /**
     * 冻结持仓
     *
     * @param accountId 持仓账户ID
     * @param volume    冻结金额
     * @param tradeType 交易类型
     * @param remark    备注
     * @return
     * @throws ForexAccountException
     */
    boolean lockAmount(
            long accountId,
            BigDecimal volume,
            TradeType tradeType,
            String remark
    ) throws ForexAccountException;

    /**
     * 解冻持仓
     *
     * @param accountId 持仓账户ID
     * @param volume    冻结金额
     * @param tradeType 交易类型
     * @param remark    备注
     * @return
     * @throws ForexAccountException
     */
    boolean unlockAmount(
            long accountId,
            BigDecimal volume,
            TradeType tradeType,
            String remark
    ) throws ForexAccountException;

}
